//
//  ComTableViewCell.m
//  WhereToTravel
//
//  Created by dllo on 15/10/15.
//  Copyright © 2015年 zhoushengmin. All rights reserved.
//

#import "ComTableViewCell.h"

#define W self.contentView.frame.size.width/375
#define H self.contentView.frame.size.height/100

@implementation ComTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [[NSNotificationCenter defaultCenter] postNotificationName:@"night" object:nil];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(night) name:@"night" object:nil];

        
        self.labelTitle = [[UILabel alloc]init];
        [self.contentView addSubview:self.labelTitle];
              
        
        self.labelUse = [[UILabel alloc]init];
        [self.contentView addSubview:self.labelUse];
   
        
        
        self.labelReplys = [[UILabel alloc]init];
        [self.contentView addSubview:self.labelReplys];
        
    }
    return self;
}



-(void)layoutSubviews
{
    [super layoutSubviews];
    self.labelTitle.frame = CGRectMake(10 * W, 10 * H, 355 * W, 45 * H);
    self.labelUse.frame = CGRectMake(10 * W, 65 * H, 265 * W, 25 * H);
    self.labelReplys.frame = CGRectMake(300 * W, 65 * H, 75 * W, 25 * H);
    
    [self.labelTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(10 * W);
        make.top.equalTo(self.contentView.mas_top).offset(10 * H);
        make.height.equalTo(@(45 * H));
        make.width.equalTo(self.contentView.mas_width).multipliedBy(0.95);
    }];
    [self.labelUse mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(10 * W);
        make.top.equalTo(self.labelTitle.mas_bottom).offset(10 * H);
        make.height.equalTo(@(25 * H));
        make.width.equalTo(@(265 * W));
    }];
    [self.labelReplys mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView.mas_right).offset(10 * W);
        make.top.equalTo(self.labelTitle.mas_bottom).offset(10 * H);
        make.height.equalTo(@(25 * H));
        make.width.equalTo(@(65 * W));
    }];
}

- (void)night {
    if ([SingletonNight shareSingletonNight].isSelete == YES) {
        self.labelTitle.textColor = [UIColor whiteColor];
        self.labelUse.textColor = [UIColor whiteColor];
        self.labelReplys.textColor = [UIColor whiteColor];
    }
    else {
        self.labelTitle.textColor = [UIColor blackColor];
        self.labelUse.textColor = [UIColor blackColor];
        self.labelReplys.textColor = [UIColor blackColor];
    }
}

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"night" object:nil];
}




- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
